MySQL UPDATE Statement
The UPDATE
statement is used to update any existing records in the table that matches the where
clause.
Syntax for UPDATE statement
UPDATE table_name
set column_1=value_1
where condition;
We shall work on the following demo table.
empno | name | age | role | location |
---|---|---|---|---|
001 | Andrew | 30 | Manager | India |
002 | Beslin | 28 | Business Analyst | India |
003 | Joanna | 23 | Senior Developer | USA |
004 | Rayan | 26 | Technical Lead | Canada |
We shall write a query to update the record of the employee
with empno
002.
update employee
set name='Beslin Pajila'
where empno=002;
The update statement is not restricted to single record. If the condition satisfies multiple records then it will update all the records of the table.